<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <input type="text">
    <button class="btn1">存储数据</button>
    <script>
        var btn1 = document.querySelector('.btn1');
        var input = document.querySelector('input');
        btn1.addEventListener('click', function () {
            var val = input.value;
            sessionStorage.setItem('username', val);//存储数据
        })
        //getItem获取数据
        //removeItem移除数据
        //clear()清空数据
    </script>
</body>

</html>